import BaseApi from '../BaseApi';

const controller = "/park";
const permission = "/permission";
const post = "/post";
const getUserList = "/user";

export default {

    parkTree() {
        return this.requestGet(controller, "/parkTree");
    },

    getParkListBy(condition) {
        return this.requestPost(controller, "/getParkListBy", condition);
    },
    //权限列表
    getPowers() {
        return this.requestGet(permission, '/permissions')
    },

    getPermissionTree() {
        return this.requestPost('/user', '/getDirectoryTree');
    },

    //岗位列表
    getStation() {
        return this.requestGet(post, '/list')
    },
    //修改岗位
    updatePosts(condition) {
        let parse = JSON.stringify(condition);
        return this.requestPostForJson(post, '/updatePost', parse)
    },
    //添加岗位
    addTreePost(condition) {
        let parse = JSON.stringify(condition);
        return this.requestPostForJson(post, "/addPost", parse);
    },
    //删除岗位
    deletePosts(condition) {
        let id = condition.id
        return this.requestGet(post, "/delPost/" + id);
    },
    /**
     * 新增/修改停车点
     * @param condition
     */
    addPark(condition) {
        return this.requestPost(controller, "/addPark", condition);
    },
    delPark(condition) {
        let id = condition.id;
        return BaseApi.requestGet(controller + "/delPark/" + id);
    },
    /**
     * 操作人员
     * @param condition
     */
    //角色列表
    getPersonList() {
        return this.requestGet(getUserList, '/roles')
    },
    //添加角色
    addPersonPost(condition) {
        let parse = JSON.stringify(condition);
        return this.requestPostForJson(getUserList, "/addRole", parse);
    },
    //获取人员岗位列表 user/roleInfo{id}
    getPersonStationList(index) {
        return this.requestGet(getUserList, '/roleInfo/' + index)
    },
    //删除角色  /user/delRole/{id}
    deleteRole(id) {
        return this.requestGet(getUserList, '/delRole/' + id);
    },
    //更新角色 /user/updateRole
    updateRole(condition) {
        let parse = JSON.stringify(condition);
        return this.requestPostForJson(getUserList, '/updateRole', parse);
    },
    //获取文件列表
    getFileList(condition) {
        // downloadManager/getDownloadList
        let url = '/downloadManager'
        return this.requestPost(url, '/getDownloadList', condition);
    },
    //获取责任区列表查询
    getControllerList(condition) {
        return this.requestPost(controller, '/getParkControllerList', condition)
    },
    /**
     * 用户操作
     * @param condition
     * @returns {*|Promise<any>|Window.Promise}
     */
    //新增用户
    addUser(condition) {
        let parse = JSON.stringify(condition);
        return this.requestPostForJson(getUserList, '/addUser', parse);
    },
    //删除用户 /delUser/{id}
    delUser(id) {
        return this.requestGet(getUserList, '/delUser/' + id);
    },
    //修改用户 /updateUser
    updateUser(condition) {
        let parse = JSON.stringify(condition);
        return this.requestPostForJson(getUserList, '/updateUser', parse);
    },
    //用户详情  /userInfo/{id}
    userInfo(id) {
        return this.requestGet(getUserList, '/userInfo/' + id);
    },
    //账号禁用/启用 switchUserAccount
    switchUserAccount(condition) {
        return this.requestPost(getUserList, '/switchUserAccount', condition);
    },

    /* 特殊车位 */
    addSpecialPlate(condition) {
        return this.requestPost("/specialPlate", '/addSpecialPlate', condition);
    },

    updateSpecialPlate(condition) {
        return this.requestPost("/specialPlate", '/updateSpecialPlate', condition);
    },

    getSpecialPlateList(condition) {
        return this.requestPost("/specialPlate", '/getSpecialPlateList', condition);
    },
    saveCallingRelated(condition) {
        return this.requestPost(controller, '/saveCallingRelated', condition);
    },
    saveNavigation(condition) {
        return this.requestPost(controller, '/saveNavigation', condition);
    },
    saveOrderPayStatus(data){
        return this.requestPost(controller, "/saveOrderPayStatus", data);
    },
    callingRelatedConfiguration() {
        return this.requestGet(controller, '/callingRelatedConfiguration');
    },

    /*请求封装*/
    requestPost(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestPost(newUrl, condition);

    },
    requestGet(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestGet(newUrl, condition);
    },
    requestPostForJson(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestPostForJson(newUrl, condition);
    },


}